package com.bantang.bizmq;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;


public class Main {

    public static void main(String[] args) {

        try {

            ConnectionFactory factory = new ConnectionFactory();

            factory.setHost("192.168.56.101");

            Connection connection = factory.newConnection();

            Channel channel = connection.createChannel();
            String EXCHANGE_NAME = "code_exchange";
            String QUEUE_NAME = "code_queue";

            channel.exchangeDeclare(EXCHANGE_NAME,"direct");
            channel.queueDeclare(QUEUE_NAME,true,false,false,null);

            channel.queueBind(QUEUE_NAME,EXCHANGE_NAME,"zhb_rotingKey");

        } catch (IOException e) {
            e.printStackTrace();
        } catch (TimeoutException e) {
            e.printStackTrace();
        }


    }
}
